package com.amit.hibernate;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

public class Lab3Client {

	public static void main(String[] args) {
		
		SessionFactory sessionfactory=CHibernateUtil.getfactory();
		Session session=sessionfactory.openSession();
		Transaction tx=session.beginTransaction();
		
		String courses[]={"Java","JDBC","JSP"};
		List<String> emails=new ArrayList<String>();
		emails.add("aa@jlc");
		emails.add("bb@jlc");
		emails.add("cc@jlc");
		
		List<Integer> marks=new ArrayList<Integer>();
		marks.add(new Integer(100));
		marks.add(new Integer(99));
		marks.add(new Integer(100));
		
		Set<Long> phones=new HashSet<Long>();
		phones.add(new Long(1111));
		phones.add(new Long(2222));
		phones.add(new Long(3333));
	
		Map<String, Long> refs= new HashMap<String, Long>();
		refs.put("aaa", new Long(1111));
		refs.put("bbb", new Long(2222));
		refs.put("ccc", new Long(3333));
		
		Student stu=new Student("amiyadav", "06-11-1988", "B.tech-cse", courses, emails, marks, phones, refs);
		session.save(stu);
		
		
		tx.commit();
		session.close();
		
		System.out.println("Record Inserted");
		
		

	}

}
